{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8301\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import json\n",
    "\n",
    "with open(\"icd11_2020_09.json\", \"r\", encoding=\"utf-8\") as f:\n",
    "    data = json.load(f)\n",
    "    coln = list(data[0].keys())\n",
    "\n",
    "    size = len(data)\n",
    "    print(size)\n",
    "\n",
    "    DF = pd.DataFrame(data, columns=coln)\n",
    "    DF = DF.set_index(\"uid\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>code</th>\n",
       "      <th>class_kind</th>\n",
       "      <th>child</th>\n",
       "      <th>parent</th>\n",
       "      <th>index_term</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>uid</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>257068234</th>\n",
       "      <td>霍乱</td>\n",
       "      <td>1A00</td>\n",
       "      <td>category</td>\n",
       "      <td>[]</td>\n",
       "      <td>[135352227]</td>\n",
       "      <td>[霍乱, 亚洲霍乱, 流行性霍乱, 霍乱综合征, Intestinal infection ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>416025325</th>\n",
       "      <td>其他弧菌的肠道感染</td>\n",
       "      <td>1A01</td>\n",
       "      <td>category</td>\n",
       "      <td>[]</td>\n",
       "      <td>[135352227]</td>\n",
       "      <td>[其他弧菌的肠道感染, 其他弧菌性肠道感染, 副溶血性弧菌引起的感染, 创伤弧菌引起的感染,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2080365623</th>\n",
       "      <td>志贺菌肠道感染</td>\n",
       "      <td>1A02</td>\n",
       "      <td>category</td>\n",
       "      <td>[]</td>\n",
       "      <td>[135352227]</td>\n",
       "      <td>[志贺菌肠道感染, 志贺菌性肠炎, 志贺菌病, 杆菌性结肠炎, 菌痢NOS, 志贺菌性肠道感...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2099226249</th>\n",
       "      <td>肠致病性大肠埃希菌感染</td>\n",
       "      <td>1A03.0</td>\n",
       "      <td>category</td>\n",
       "      <td>[]</td>\n",
       "      <td>[344162786]</td>\n",
       "      <td>[肠致病性大肠埃希菌感染, EPEC[肠致病性大肠埃希菌]感染, 肠致病性大肠埃希菌感染引起...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>408185629</th>\n",
       "      <td>产肠毒素性大肠埃希菌感染</td>\n",
       "      <td>1A03.1</td>\n",
       "      <td>category</td>\n",
       "      <td>[]</td>\n",
       "      <td>[344162786]</td>\n",
       "      <td>[产肠毒素性大肠埃希菌感染, ETEC[产肠毒素性大肠埃希菌]感染, 产肠毒素性大肠埃希菌感...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1833083626</th>\n",
       "      <td>先天性隔离肺</td>\n",
       "      <td>LA75.6</td>\n",
       "      <td>category</td>\n",
       "      <td>[]</td>\n",
       "      <td>[1749762534]</td>\n",
       "      <td>[先天性隔离肺, 先天性隔离肺, 叶内型肺隔离症, 叶外型肺隔离症]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1749762534</th>\n",
       "      <td>肺结构发育异常</td>\n",
       "      <td>LA75</td>\n",
       "      <td>category</td>\n",
       "      <td>[435155477, 134836096, 1778475393, 1469394441,...</td>\n",
       "      <td>[1122022750]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1205685953</th>\n",
       "      <td>胸膜结构发育异常</td>\n",
       "      <td>LA76</td>\n",
       "      <td>category</td>\n",
       "      <td>[]</td>\n",
       "      <td>[1122022750]</td>\n",
       "      <td>[胸膜结构发育异常, 胸膜畸形, 胸膜畸形, 胸膜畸形, 胸膜畸形, 单侧胸膜发育异常, 双...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>580289365</th>\n",
       "      <td>先天性纵隔囊肿</td>\n",
       "      <td>LA77</td>\n",
       "      <td>category</td>\n",
       "      <td>[]</td>\n",
       "      <td>[1122022750]</td>\n",
       "      <td>[先天性纵隔囊肿]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1122022750</th>\n",
       "      <td>呼吸系统结构发育异常</td>\n",
       "      <td></td>\n",
       "      <td>block</td>\n",
       "      <td>[484839707, 2041437327, 271795917, 679333287, ...</td>\n",
       "      <td>[258484393]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8301 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                    name    code class_kind  \\\n",
       "uid                                           \n",
       "257068234             霍乱    1A00   category   \n",
       "416025325      其他弧菌的肠道感染    1A01   category   \n",
       "2080365623       志贺菌肠道感染    1A02   category   \n",
       "2099226249   肠致病性大肠埃希菌感染  1A03.0   category   \n",
       "408185629   产肠毒素性大肠埃希菌感染  1A03.1   category   \n",
       "...                  ...     ...        ...   \n",
       "1833083626        先天性隔离肺  LA75.6   category   \n",
       "1749762534       肺结构发育异常    LA75   category   \n",
       "1205685953      胸膜结构发育异常    LA76   category   \n",
       "580289365        先天性纵隔囊肿    LA77   category   \n",
       "1122022750    呼吸系统结构发育异常              block   \n",
       "\n",
       "                                                        child        parent  \\\n",
       "uid                                                                           \n",
       "257068234                                                  []   [135352227]   \n",
       "416025325                                                  []   [135352227]   \n",
       "2080365623                                                 []   [135352227]   \n",
       "2099226249                                                 []   [344162786]   \n",
       "408185629                                                  []   [344162786]   \n",
       "...                                                       ...           ...   \n",
       "1833083626                                                 []  [1749762534]   \n",
       "1749762534  [435155477, 134836096, 1778475393, 1469394441,...  [1122022750]   \n",
       "1205685953                                                 []  [1122022750]   \n",
       "580289365                                                  []  [1122022750]   \n",
       "1122022750  [484839707, 2041437327, 271795917, 679333287, ...   [258484393]   \n",
       "\n",
       "                                                   index_term  \n",
       "uid                                                            \n",
       "257068234   [霍乱, 亚洲霍乱, 流行性霍乱, 霍乱综合征, Intestinal infection ...  \n",
       "416025325   [其他弧菌的肠道感染, 其他弧菌性肠道感染, 副溶血性弧菌引起的感染, 创伤弧菌引起的感染,...  \n",
       "2080365623  [志贺菌肠道感染, 志贺菌性肠炎, 志贺菌病, 杆菌性结肠炎, 菌痢NOS, 志贺菌性肠道感...  \n",
       "2099226249  [肠致病性大肠埃希菌感染, EPEC[肠致病性大肠埃希菌]感染, 肠致病性大肠埃希菌感染引起...  \n",
       "408185629   [产肠毒素性大肠埃希菌感染, ETEC[产肠毒素性大肠埃希菌]感染, 产肠毒素性大肠埃希菌感...  \n",
       "...                                                       ...  \n",
       "1833083626                 [先天性隔离肺, 先天性隔离肺, 叶内型肺隔离症, 叶外型肺隔离症]  \n",
       "1749762534                                                 []  \n",
       "1205685953  [胸膜结构发育异常, 胸膜畸形, 胸膜畸形, 胸膜畸形, 胸膜畸形, 单侧胸膜发育异常, 双...  \n",
       "580289365                                           [先天性纵隔囊肿]  \n",
       "1122022750                                                 []  \n",
       "\n",
       "[8301 rows x 6 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "DF"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python (cdss)",
   "language": "python",
   "name": "cdss"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
